package com.sskj.spk.ui.fragment;


import android.os.Bundle;
import android.support.v7.widget.AppCompatTextView;
import android.widget.TextView;

import com.sskj.spk.R;
import com.sskj.spk.bean.SummaryBean;
import com.sskj.spk.presenter.SummaryPresenter;
import com.sskj.lib.Constans;
import com.sskj.lib.base.BaseFragment;
import com.sskj.lib.bean.StockCoinBean;

import butterknife.BindView;

/**
 * 币种简介
 *
 * @author Hey
 * created at 2018/4/10 17:18
 */
public class SummaryFragment extends BaseFragment<SummaryPresenter> {

    @BindView(R.id.summary_name)
    TextView summaryName;
    @BindView(R.id.summary_crateTime)
    TextView summaryCrateTime;
    @BindView(R.id.summary_create_num)
    TextView summaryCreateNum;

    @BindView(R.id.summary_white_paper)
    TextView summaryWhitePaper;
    @BindView(R.id.summary_website)
    TextView summaryWebsite;
    @BindView(R.id.summary_content)
    TextView summaryContent;
    String code;

    public SummaryFragment() {

    }


    @Override
    public int getLayoutId() {
        return R.layout.app_fragment_summary;
    }

    @Override
    public SummaryPresenter getPresenter() {
        return new SummaryPresenter();
    }

    @Override
    public void initView() {

    }

    @Override
    public void initData() {
        code = getArguments().getString(Constans.CODE);
        mPresenter.getData(code);
        summaryName.setText(code.split("/")[0]);//币名字
    }

    /**
     * @param code 币种编号
     * @param
     * @return
     */
    public static SummaryFragment newInstance(String code) {
        SummaryFragment fragment = new SummaryFragment();
        Bundle bundle = new Bundle();
        bundle.putString(Constans.CODE, code);
        fragment.setArguments(bundle);
        return fragment;
    }

    public void setData(SummaryBean data) {
        if (summaryName == null || data == null)
            return;
        summaryCrateTime.setText(data.getFxtime());//发行时间
        summaryCreateNum.setText(data.getFxnum());//发行总量
        summaryWhitePaper.setText(data.getFxbook());
        summaryWebsite.setText(data.getFxbook());
        summaryContent.setText(data.getMemo());
    }
}
